App({
    onLaunch: function() {
        //调用API从本地缓存中获取数据
        //var logs = wx.getStorageSync('logs') || []
        //logs.unshift(Date.now())
        //wx.setStorageSync('logs', logs)
    },
    getUserInfo: function(cb) {
        var that = this
        if (this.globalData.userInfo) {
            typeof cb == "function" && cb(this.globalData.userInfo)
        } else {
            //调用登录接口
            wx.login({
                success: function(r) {
                    that.globalData.userCode = r.code;
                    wx.getUserInfo({
                        success: function(res) {
                            that.globalData.userInfo = res.userInfo;
                            typeof cb == "function" && cb(that.globalData.userInfo);
                        },
                        fail: function(res) {
                            typeof cb == "function" && cb(that.globalData.userInfo);
                        }
                    })
                }
            })
        }
    },

    setUserSid: function(sid) {
        this.globalData.userSid = sid;
    },
    getUserSid: function() {
        return this.globalData.userSid;
    },
    setOpenId(openId) {
        this.globalData.openId = openId;
    },
    getOpenId() {
        return this.globalData.openId;
    },
    getHost() {
        return this.config.apiUrl;
    },
    setHost(host) {
        this.config.apiUrl = host;
    },
    getAlias() {
        return this.globalData.alias;
    },
    setAlias(alias) {
        this.globalData.alias = alias;
    },
    setLocation(lat, lng) {
        this.globalData.location = {
            lng,
            lat,
        };
    },
    getLocation() {
        return this.globalData.location;
    },
    getUserId() {
        return this.globalData.user_id;
    },
    setUserId(user_id) {
        this.globalData.user_id = user_id;
    },
    getWinHei() {
        return this.globalData.winHei;
    },
    setWinHei(winHei) {
        this.globalData.winHei = winHei;
    },
    getWinWid() {
        return this.globalData.winWid;
    },
    setWinWid(winWid) {
        this.globalData.winWid = winWid;
    },
    getEmployeeSid(){
        return this.globalData.eSid;
    },
    setEmployeeSid(eSid){
        this.globalData.eSid = eSid;
    },
    getLogoImg(){
        return this.globalData.logoImg;
    },
    setLogoImg(logoImg){
        this.globalData.logoImg = logoImg;
    },
    getShareTitle(){
        return this.globalData.shareTit;
    },
    setShareTitle(shareTitle){
        this.globalData.shareTitle = shareTitle;
    },
    getMarketTitle(){
        return this.globalData.marketTitle;
    },
    setMarketTitle(marketTitle){
        this.globalData.marketTitle = marketTitle;
    },
    globalData: {
        openId: null,
        userSid: '',
        userInfo: null,
        location: {
            lng: '',
            lat: '',
        },
        isPay: false,
        user_id: null,

        winHei:0,
        winWid:0,
        eSid:null,
        logoImg:null,
        marketTitle:null,
        shareTitle:null
    },
    config: {
        apiUrl: 'https://api.y.88ff.com',
    }
})